package org.kisekiproject.log {

	/**
	 * Log
	 */
	public class Log {

		private static var _loggers:Array;

		/**
		 * Log a message.
		 */
		private static function message(msg:String):void {
			if (!_loggers)
				initialize();

			for each (var logger:ILogger in _loggers)
				logger.message(msg);
		}

		/**
		 * Initialize.
		 */
		private static function initialize():void {
			_loggers=new Array();

			addLogger(new TraceLogger());
		}

		/**
		 * Add a logger.
		 */
		public static function addLogger(logger:ILogger):void {
			if (!_loggers)
				initialize();

			_loggers.push(logger);
		}

		/**
		 * Debug message.
		 */
		public static function debug(message:String):void {
			Log.message("DEBUG: "+message);
		}

		/**
		 * Info message.
		 */
		public static function info(message:String):void {
			Log.message("INFO: "+message);
		}

		/**
		 * Warning message.
		 */
		public static function warning(message:String):void {
			Log.message("WARNING: "+message);
		}

		/**
		 * Error message.
		 */
		public static function error(message:String):void {
			Log.message("ERROR: "+message);
		}
	}
}